package com.fcscs.cservice.client.main.configuration.checkin;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.FieldEvent;
import com.extjs.gxt.ui.client.event.IconButtonEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.Validator;
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.fcscs.core.common.authority.CServiceAuthority;
import com.fcscs.core.common.authority.UserAuthority;
import com.fcscs.core.domain.IdNameModel;
import com.fcscs.core.domain.Property;
import com.fcscs.core.gwt.common.AsyncCallbackListener;
import com.fcscs.core.gwt.common.CoreConstants;
import com.fcscs.core.gwt.common.SessionContext;
import com.fcscs.core.gwt.common.ui.CenteredInfo;
import com.fcscs.core.gwt.common.ui.FcsFields.EasyClearCombobox;
import com.fcscs.core.gwt.common.ui.FcsFields.FormButton;
import com.fcscs.core.gwt.common.ui.FcsFields.HighLightIconButton;
import com.fcscs.core.gwt.common.ui.FcsPanel;
import com.fcscs.cservice.client.common.CServiceConstants;
import com.fcscs.cservice.client.common.MultiLanguageConstants;
import com.fcscs.cservice.client.common.UIUtils;
import com.fcscs.cservice.client.common.controller.CServiceCommonServiceController;
import com.fcscs.cservice.client.common.model.configuration.checkin.MessageItemsExpressGWTEnum;
import com.fcscs.cservice.client.common.model.configuration.checkin.MessageItemsExpressGWTEnumModelData;
import com.fcscs.cservice.client.common.model.configuration.checkin.MessageItemsGWTEnum;
import com.fcscs.cservice.client.common.model.configuration.checkin.MessageItemsGWTEnumModelData;
import com.fcscs.cservice.client.common.model.configuration.reservation.PropertyIdNameModelData;
import com.fcscs.cservice.domain.ConstantsLanguageValue;
import com.fcscs.cservice.domain.ConstantsLanguageValueId;
import com.fcscs.cservice.domain.ExpressCheckInConfig;
import com.fcscs.share.gwt.common.ShareGWTConstants;
import com.fcscs.share.gwt.common.ui.MultiLanguageDialog;
import com.fcscs.share.gwt.common.ui.event.MultiLanguageDialogEventHandler;
import com.fcscs.share.gwt.common.ui.event.MultiLanguageDialogOKEvent;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;

public class ExpressCheckInConfigPanel extends FcsPanel {
	private VerticalPanel vp;
	private FieldSet fieldset1;
	private FieldSet fieldset2;
	private FieldSet fieldset3;
	private FieldSet fieldset4;
	private FieldSet fieldset5;
	private FieldSet fieldset6;
	private Radio emailRadio;
	private Radio printerRadio;
	private TextField<String> emailAddressField;
	private TextField<String> serverNameField;
	private TextField<String> fromExpressCheckin;
	private TextField<String> subjectCheckin;
	private TextField<String> subjectCheckinTimeout;
	private EasyClearCombobox<MessageItemsExpressGWTEnumModelData> titleMessageItemsCombox;
	private EasyClearCombobox<MessageItemsGWTEnumModelData> titleMessageItemsComboxformService;
	private ListStore<MessageItemsExpressGWTEnumModelData> titleMessageItemsListStore;
	private ListStore<MessageItemsGWTEnumModelData> titleMessageItemsListStoreformService;
	private TextField<String> titleField;
	private TextField<String> titleFieldformService;
	private TextField<String> checkinrequestsubmitted;
	private TextField<String> alreadycheckin;
	private EasyClearCombobox<MessageItemsGWTEnumModelData> messageItemsCombox;
	private ListStore<MessageItemsGWTEnumModelData> messageItemsListStore;
	private TextArea textArea;
	private TextArea textAreaexpresscheckin;
	private TextField<String> timeOutField;
	private Radio emailRadioAlert;
	private Radio printerRadioAlert;
	private TextField<String> emailAddressFieldAlert;
	private TextField<String> serverNameFieldAlert;
	private EasyClearCombobox<MessageItemsGWTEnumModelData> titleMessageItemsCombox1;
	private ListStore<MessageItemsGWTEnumModelData> titleMessageItemsListStore1;
	private TextField<String> titleField1;
	private EasyClearCombobox<MessageItemsGWTEnumModelData> messageItemsCombox1;
	private ListStore<MessageItemsGWTEnumModelData> messageItemsListStore1;
	private TextArea textArea1;
	private TextField<String> ackField;
	private ExpressCheckInConfig currentExpressCheckInConf;
	private boolean isFocus = true;
	private EasyClearCombobox<PropertyIdNameModelData> propCombox;
	private ListStore<PropertyIdNameModelData> propListStore;
	private List<IdNameModel<Property>> propGroupIdNames;
	private MultiLanguageDialog fromDialog;
	private MultiLanguageDialog subjectCheckinRequestDialog;
	private MultiLanguageDialog subjectCheckinRequestTimeoutDialog;
	private MultiLanguageDialog checkinRequestSubmittedDialog;
	private MultiLanguageDialog alreadyCheckinDialog;
	private Map<String, String> fromExpresscheckinMap;
	private Map<String, String> subjectCheckinRequestMap;
	private Map<String, String> subjectCheckinRequestTimeoutMap;
	private Map<String, String> checkinRequestSubmittedMap;
	private Map<String, String> alreadyCheckinMap;
	private boolean isChange;
	private String currentFromExpressCheckIn;
	private String currentSubjectCheckInRequest;
	private String currentSubjectAlertTimeout;
	private String currentCheckinSubmitted;
	private String currentAlreadyCheckin;
	
	private FormButton saveButton;
	private FieldSet fieldsetCheckInMesTem;
	private FieldSet fieldsetCheckInMesTemAlert;
	private FieldSet fieldsetCheckInTimeoutAlet;
	
	public ExpressCheckInConfigPanel(String id) {
		super(id);
	}

	public HighLightIconButton MultiEditBtn(){
		HighLightIconButton iconBtn = new HighLightIconButton(
				ShareGWTConstants.CSS_EDIT_SM_ICON, new SelectionListener<IconButtonEvent>() {
					public void componentSelected(IconButtonEvent ie){
						//dialog show method
					}
				});
		iconBtn.setTitle(CoreConstants.CORE_CONSTANTS.edit());
		return iconBtn;
	}

	@Override
	public void init() {
		
		currentExpressCheckInConf = new ExpressCheckInConfig();		
		
		vp = new VerticalPanel();
		vp.setId("ExpressCheckInConfigPanel_vpPanel");
		vp.setSpacing(5);
		
		LayoutContainer lc = new LayoutContainer();
		lc.setId("ExpressCheckInConfigPanel_lc");
		lc.setLayout(new ColumnLayout());
		
		Label propLabel = new Label(CoreConstants.CORE_CONSTANTS.property() + CoreConstants.REQURIED_FIELD_LABEL);
		propLabel.setId("ExpressCheckInConfigPanel_propLabel");
		
		propListStore = new ListStore<PropertyIdNameModelData>();
		propCombox = new EasyClearCombobox<PropertyIdNameModelData>();
		propCombox.setId("ExpressCheckInConfigPanel_propCombox");
//		propCombox.setFieldLabel(CoreConstants.CORE_CONSTANTS.property());
		propCombox.setWidth(200);
		propCombox.setDisplayField(CoreConstants.FULLTNAME);
		propCombox.setAllowBlank(false);
		propCombox.setForceSelection(true);
		propCombox.setTriggerAction(TriggerAction.ALL);
		propCombox.setStore(propListStore);
		propCombox.addSelectionChangedListener(new SelectionChangedListener<PropertyIdNameModelData>(){
			@Override
			public void selectionChanged(SelectionChangedEvent<PropertyIdNameModelData> se) {
				myClear();
//				ReservationServiceController.getINSTANCE().getCheckInConf(
//						propCombox.getValue().getEntity().getId(), 
//						new AsyncCallbackListener<CheckInConfiguration>(){
//							@Override
//							public void onLogin(String username) {
//								ReservationServiceController.getINSTANCE().getCheckInConf(
//										SessionContext.getInstance().getPropertyId(),this);
//							}
//							@Override
//							public void onFailure(Throwable caught) {
//								MessageBox.alert(CoreConstants.CORE_MESSAGES.operation(CoreConstants.CORE_CONSTANTS.system(), ShareGWTConstants.SHARE_GWT_CONSTANTS.error()),
//										CoreConstants.CORE_CONSTANTS.systemError(), null);
//							}
//							@Override
//							public void onSuccess(CheckInConfiguration result) {
//								if(null != result){
//									currentCheckInConf = result;
//									if(null != result.getReqDest()
//										&& result.getReqDest().getDestTypeEnum().equals(NotifDestType.EMAIL)){
//										isFocus = true;
//										printerRadio.setValue(false);
//										emailRadio.setValue(true);
//										emailAddressField.setValue(result.getReqDest().getDestination());
//									}else if(null != result.getReqDest()
//										&& result.getReqDest().getDestTypeEnum().equals(NotifDestType.PRINTER)){
//										isFocus = false;
//										emailRadio.setValue(false);
//										printerRadio.setValue(true);
//										serverNameField.setValue(result.getReqDest().getDestination());
//									}
//									
//									if(null != result.getReqTmpl()){
//										titleField.setValue(result.getReqTmpl().getTitle());
//										textArea.setValue(result.getReqTmpl().getDetail());
//									}
//									
//									timeOutField.setValue(result.getReqTimeout()+"");
//									
//									if(null != result.getToAlertDest()
//											&& result.getToAlertDest().getDestTypeEnum().equals(NotifDestType.EMAIL)){
//											printerRadioAlert.setValue(false);
//											emailRadioAlert.setValue(true);
//											emailAddressField1.setValue(result.getToAlertDest().getDestination());
//									}else if(null != result.getToAlertDest()
//											&& result.getToAlertDest().getDestTypeEnum().equals(NotifDestType.PRINTER)){
//											emailRadioAlert.setValue(false);
//											printerRadioAlert.setValue(true);
//											serverNameField1.setValue(result.getToAlertDest().getDestination());
//									}
//									
//									if(null != result.getToAlertTmpl()){
//										titleField1.setValue(result.getToAlertTmpl().getTitle());
//										textArea1.setValue(result.getToAlertTmpl().getDetail());
//									}
//								}
//							}
//						});
			}
		});
		
		lc.add(propLabel, new ColumnData(70));
		lc.add(propCombox, new ColumnData(160));
		
		vp.add(lc);
		
		FormPanel panel = new FormPanel();
		panel.setId("ExpressCheckInConfigPanel_panel");
		panel.setFrame(true);
		panel.setHeading(CServiceConstants.CSERVICE_CONSTANTS.expressCheckin());
		panel.setPadding(10);
		panel.setSize(730, 530);
		panel.setScrollMode(Scroll.AUTOY);
		panel.setLabelAlign(LabelAlign.LEFT);
		panel.setLabelSeparator("");
		panel.setLabelWidth(100);
		panel.setFieldWidth(400);
		
		LayoutContainer lca = new LayoutContainer();
		
		fieldset1 = new FieldSet();
		fieldset1.setWidth(650);
		fieldset1.setId("ExpressCheckInConfigPanel_fieldset1");
		fieldset1.setHeading(CServiceConstants.CSERVICE_CONSTANTS.checkInRequestSendTo());
		fieldset1.add(lca);
	    panel.add(fieldset1);
		
		HorizontalPanel checkinsendtohp = new HorizontalPanel();
		VerticalPanel emailprinterradiovp = new VerticalPanel();
		emailprinterradiovp.setSpacing(5);
		VerticalPanel emailprintertextvp = new VerticalPanel();
		emailprintertextvp.setSpacing(5);
		
		lca.setId("ExpressCheckInConfigPanel_lca");
	    FormLayout layout = new FormLayout();
		layout.setLabelAlign(LabelAlign.LEFT);
		layout.setLabelWidth(100);
		layout.setDefaultWidth(360);
		layout.setLabelSeparator("");
		lca.setLayout(layout);
		lca.setBorders(false);
		
		Label label = new Label("<html><font size=\"3\">" 
				                + CServiceConstants.CSERVICE_CONSTANTS.checkInRequestSendTo()
				                + "</font></html>");
		label.setId("ExpressCheckInConfigPanel_label");
//		lca.add(label);
		
		emailRadio = new Radio();
		emailRadio.setId("ExpressCheckInConfigPanel_emailRadio");
		emailRadio.setBoxLabel(CServiceConstants.CSERVICE_CONSTANTS.emailAddress());
//		emailRadio.setValue(true);
		emailRadio.addListener(Events.Change, new Listener<BaseEvent>(){
			@Override
			public void handleEvent(BaseEvent be) {
				if(emailRadio.getValue()){
					if(currentExpressCheckInConf.getCheckInRequestSendTo()==1 || isChange){
						saveButton.setEnabled(true);
						isChange=true;
					}
					printerRadio.setValue(false);
					emailAddressField.setEnabled(true);
					emailAddressField.focus();
					serverNameField.setEnabled(false);
					serverNameField.clear();
//					if(emailAddressField.getValue().equals("")){
						
//					}
				}
//				else{
//					emailAddressField.setEnabled(false);
////					emailAddressField.setVisible(false);
////					emailAddressField.clear();
//				}
			}
			
	    });

		printerRadio = new Radio();
		printerRadio.setId("ExpressCheckInConfigPanel_printerRadio");
		printerRadio.setBoxLabel(ShareGWTConstants.SHARE_GWT_CONSTANTS.printer() + " " + CServiceConstants.CSERVICE_CONSTANTS.serverName() + CServiceConstants.FIELD_SEP);
//		printerRadio.setValue(false);
		printerRadio.addListener(Events.Change, new Listener<BaseEvent>(){
			@Override
			public void handleEvent(BaseEvent be) {
				if(printerRadio.getValue()){
					if(currentExpressCheckInConf.getCheckInRequestSendTo()==0 || isChange){
						saveButton.setEnabled(true);
						isChange=true;
					}
					emailRadio.setValue(false);
					serverNameField.setEnabled(true);
					serverNameField.focus();
					emailAddressField.setEnabled(false);
					emailAddressField.clear();
				}
//				else{
//					serverNameField.setEnabled(false);
////					serverNameField.setVisible(false);
////					serverNameField.clear();
//				}
			}
	    });
	    
	    emailprinterradiovp.add(emailRadio);
	    emailprinterradiovp.add(printerRadio);
	    
	    emailAddressField = new TextField<String>();
	    emailAddressField.setId("ExpressCheckInConfigPanel_emailAddressField");
	    emailAddressField.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.emailAddress() + CServiceConstants.FIELD_SEP);
//	    emailAddressField.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "80px");
	    emailAddressField.setVisible(true);
	    emailAddressField.setEnabled(true);
	    emailAddressField.setWidth(300);
	    emailAddressField.setAllowBlank(false);
	    final String emailReg = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
	    emailAddressField.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if (!value.toUpperCase().matches(emailReg)) {
					return ShareGWTConstants.SHARE_GWT_CONSTANTS.emailErro();
				} else if (value.length() > 50) {
					return ShareGWTConstants.SHARE_GWT_MESSAGES.outOfLength(
							CoreConstants.CORE_CONSTANTS.email(), 50);
				}
				return null;
			}
        });
	    emailAddressField.addListener(Events.KeyUp, new Listener<BaseEvent>() {

			@Override
			public void handleEvent(BaseEvent be) {
				// TODO Auto-generated method stub
				if(!emailAddressField.getValue().trim().equals(currentExpressCheckInConf.getCheckInPrinterEmail()) || isChange){
					saveButton.setEnabled(true);
					isChange=true;
				}
				else
					saveButton.setEnabled(false);
			}
		});
	    
	    serverNameField = new TextField<String>();
	    serverNameField.setId("ExpressCheckInConfigPanel_serverNameField");
	    serverNameField.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.serverName() + CServiceConstants.FIELD_SEP);
//	    serverNameField.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "80px");
	    serverNameField.setVisible(true);
	    serverNameField.setEnabled(false);
	    serverNameField.setWidth(300);
	    serverNameField.setAllowBlank(false);
	    serverNameField.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if(value != null 
				   && !value.trim().isEmpty()
				   && value.trim().length() > 50){
					return ShareGWTConstants.SHARE_GWT_MESSAGES.outOfLength(
							CServiceConstants.CSERVICE_CONSTANTS.serverName(), 50);
				}
				return null;
			}
        });
	    serverNameField.addListener(Events.KeyUp, new Listener<BaseEvent>() {

			@Override
			public void handleEvent(BaseEvent be) {
				// TODO Auto-generated method stub
				if(!serverNameField.getValue().trim().equals(currentExpressCheckInConf.getCheckInPrinterEmail()) || isChange){
					saveButton.setEnabled(true);
					isChange=true;
				}
				else
					saveButton.setEnabled(false);
			}
		});
	    
	    emailprintertextvp.add(emailAddressField);
	    emailprintertextvp.add(serverNameField);
	    
	    checkinsendtohp.add(emailprinterradiovp);
	    checkinsendtohp.add(emailprintertextvp);
	    
	    lca.add(checkinsendtohp);
	    
	    LayoutContainer lcb = new LayoutContainer();
	    
	    fieldset2 = new FieldSet();
		fieldset2.setWidth(650);
		fieldset2.setId("ExpressCheckInConfigPanel_fieldset2");
		fieldset2.setHeading(CServiceConstants.CSERVICE_CONSTANTS.checkInRequestMessage());
		fieldset2.add(lcb);
	    panel.add(fieldset2);
	    
	    lcb.setId("ExpressCheckInConfigPanel_lcb");
	    layout = new FormLayout();
		layout.setLabelAlign(LabelAlign.LEFT);
		layout.setLabelWidth(130);
		layout.setDefaultWidth(360);
		layout.setLabelSeparator("");
		lcb.setLayout(layout);
		lcb.setBorders(false);
	    
		fromExpressCheckin = new TextField<String>();
	    fromExpressCheckin.setId("ExpressCheckInConfigPanel_fromExpressCheckin");
	    fromExpressCheckin.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.fromexpresscheckin());
//	    serverNameField.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "80px");
	    fromExpressCheckin.setVisible(true);
	    fromExpressCheckin.setEnabled(true);
	    fromExpressCheckin.setReadOnly(true);
	    fromExpressCheckin.setWidth(400);
	    fromExpressCheckin.setValue(CServiceConstants.CSERVICE_CONSTANTS.expressCheckin());
	    fromExpressCheckin.setAllowBlank(false);
//	    serverNameField.setVisible(false);
	    fromExpressCheckin.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if(value != null 
				   && !value.trim().isEmpty()
				   && value.trim().length() > 100){
					return ShareGWTConstants.SHARE_GWT_MESSAGES.outOfLength(
							CServiceConstants.CSERVICE_CONSTANTS.expressCheckin(), 100);
				}
				return null;
			}
        });

		subjectCheckin = new TextField<String>();
		subjectCheckin.setId("ExpressCheckInConfig_subjectCheckin");
		subjectCheckin.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.subjectcheckin());
//	    serverNameField.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "80px");
		subjectCheckin.setVisible(true);
		subjectCheckin.setEnabled(true);
		subjectCheckin.setReadOnly(true);
		subjectCheckin.setWidth(400);
		subjectCheckin.setAllowBlank(false);
		subjectCheckin.setValue(CServiceConstants.CSERVICE_CONSTANTS.Checkin());
	    
//	    serverNameField.setVisible(false);
		subjectCheckin.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if(value != null 
				   && !value.trim().isEmpty()
				   && value.trim().length() > 100){
					return ShareGWTConstants.SHARE_GWT_MESSAGES.outOfLength(
							CServiceConstants.CSERVICE_CONSTANTS.subjectcheckin(), 100);
				}
				return null;
			}
        });
		
		Label label1c = new Label("<html><font size=\"3\">" 
                + CServiceConstants.CSERVICE_CONSTANTS.checkInRequestMessageTemplate()
                + "</font></html>");
		label1c.setStyleAttribute(CServiceConstants.CSS_MARGINTOP, "80px");
	    
	    layout = new FormLayout();
		layout.setLabelAlign(LabelAlign.LEFT);
		layout.setLabelWidth(130);
		layout.setDefaultWidth(360);
		layout.setLabelSeparator("");
		
		Label from = new Label(CServiceConstants.CSERVICE_CONSTANTS.fromexpresscheckin());
		Label subject = new Label(CServiceConstants.CSERVICE_CONSTANTS.subjectcheckin());
		
		HorizontalPanel fromExpressCheckinhp = new HorizontalPanel();
		VerticalPanel fromsubjectlabelvp = new VerticalPanel();
		VerticalPanel fromsubjecttextfieldvp = new VerticalPanel();
		VerticalPanel fromsubjecticonvp = new VerticalPanel();
		fromExpressCheckinhp.setSpacing(5);
		fromsubjectlabelvp.setSpacing(8);
		fromsubjectlabelvp.setWidth(103);
		fromsubjecttextfieldvp.setSpacing(5);
		fromsubjecticonvp.setSpacing(8);
		
		fromDialog = new MultiLanguageDialog();
		fromDialog.setAllowBlank(false);
		fromDialog.addMultiLanguageDialogEventHandler(new MultiLanguageDialogEventHandler() {

			@Override
			public void onButtonOKClicked(
					MultiLanguageDialogOKEvent event) {
				// Get map language-text
				Map<String, String> values = event.getSource().getLanguageTexts();
				// Display English in label
				fromExpressCheckin.setValue(values.get(MultiLanguageDialog.DEFAULT_LANGUAGE));
				
				if(!currentFromExpressCheckIn.equals(values.get(MultiLanguageDialog.DEFAULT_LANGUAGE))||isChange){
					saveButton.setEnabled(true);
					isChange=true;
				}
				else
					saveButton.setEnabled(false);
				//netTextField.setValue(values.get("ja"));
				//Info.display("result", values.get("en_us") + "-" + values.get("ko"));

			}
		});
		final HighLightIconButton fromExpressCheckinBtn = new HighLightIconButton(
				ShareGWTConstants.CSS_EDIT_SM_ICON,
				new SelectionListener<IconButtonEvent>() {
					@Override
					public void componentSelected(IconButtonEvent ce) {
						fromDialog.show();
					}
				});
		
		subjectCheckinRequestDialog = new MultiLanguageDialog();
		subjectCheckinRequestDialog.setAllowBlank(false);
		subjectCheckinRequestDialog.addMultiLanguageDialogEventHandler(new MultiLanguageDialogEventHandler() {

			@Override
			public void onButtonOKClicked(
					MultiLanguageDialogOKEvent event) {
				// Get map language-text
				Map<String, String> values = event.getSource().getLanguageTexts();
				// Display English in label
				subjectCheckin.setValue(values.get(MultiLanguageDialog.DEFAULT_LANGUAGE));
				
				if(!currentSubjectCheckInRequest.equals(values.get(MultiLanguageDialog.DEFAULT_LANGUAGE))||isChange){
					saveButton.setEnabled(true);
					isChange=true;
				}
				else
					saveButton.setEnabled(false);
				//netTextField.setValue(values.get("ja"));
				//Info.display("result", values.get("en_us") + "-" + values.get("ko"));

			}
		});
		final HighLightIconButton subjectCheckinRequestBtn = new HighLightIconButton(
				ShareGWTConstants.CSS_EDIT_SM_ICON,
				new SelectionListener<IconButtonEvent>() {
					@Override
					public void componentSelected(IconButtonEvent ce) {
						subjectCheckinRequestDialog.show();
					}
				});
		
		fromsubjectlabelvp.add(from);
		fromsubjectlabelvp.add(subject);
		fromsubjecttextfieldvp.add(fromExpressCheckin);
		fromsubjecttextfieldvp.add(subjectCheckin);
		fromsubjecticonvp.add(fromExpressCheckinBtn);
		fromsubjecticonvp.add(subjectCheckinRequestBtn);
		
		fromExpressCheckinhp.add(fromsubjectlabelvp);
		fromExpressCheckinhp.add(fromsubjecttextfieldvp);
		fromExpressCheckinhp.add(fromsubjecticonvp);
		
		lcb.add(fromExpressCheckinhp);
		
		LayoutContainer lcCheckInMesTem = new LayoutContainer();
		
		fieldsetCheckInMesTem = new FieldSet();
		fieldsetCheckInMesTem.setWidth(650);
		fieldsetCheckInMesTem.setId("ExpressCheckInConfigPanel_fieldsetCheckInMesTem");
		fieldsetCheckInMesTem.setHeading(CServiceConstants.CSERVICE_CONSTANTS.checkInRequestMessageTemplate());
		fieldsetCheckInMesTem.add(lcCheckInMesTem);
	    panel.add(fieldsetCheckInMesTem);	    
	    
	    lcCheckInMesTem.setId("ExpressCheckInConfigPanel_lcCheckInMesTem");
	    layout = new FormLayout();
		layout.setLabelAlign(LabelAlign.LEFT);
		layout.setLabelWidth(130);
		layout.setDefaultWidth(360);
		layout.setLabelSeparator("");
		lcCheckInMesTem.setLayout(layout);
		lcCheckInMesTem.setBorders(false);
	    
//	    titleMessageItemsListStoreformService = new ListStore<MessageItemsGWTEnumModelData>();
//        for(MessageItemsGWTEnum cm : MessageItemsGWTEnum.values()){
//			titleMessageItemsListStoreformService.add(new MessageItemsGWTEnumModelData(cm));
//        }
//	    
//        titleMessageItemsComboxformService = new EasyClearCombobox<MessageItemsGWTEnumModelData>();
//        titleMessageItemsComboxformService.setId("ExpressCheckInConfigPanel_titleMessageItemsComboxformService");
//        titleMessageItemsComboxformService.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.messageField() + CServiceConstants.FIELD_SEP);
//        titleMessageItemsComboxformService.setDisplayField(CoreConstants.FULLTNAME);
//        titleMessageItemsComboxformService.setTriggerAction(TriggerAction.ALL);
//        titleMessageItemsComboxformService.setStore(titleMessageItemsListStoreformService);
//        titleMessageItemsComboxformService.setForceSelection(true);
//        titleMessageItemsComboxformService.setEditable(false);
//        titleMessageItemsComboxformService.setWidth(400);
//        titleMessageItemsComboxformService.addSelectionChangedListener(new SelectionChangedListener<MessageItemsGWTEnumModelData>(){
//			@Override
//			public void selectionChanged(
//					SelectionChangedEvent<MessageItemsGWTEnumModelData> se) {
//				if(titleMessageItemsComboxformService.getValue() != null){
//					titleFieldformService.setValue((titleFieldformService.getValue() == null ? "" : titleFieldformService.getValue()) 
//							+ com.fcscs.cservice.common.CServiceConstants.NOTIF_TMPL_DELIM_LEFT 
//							+ titleMessageItemsComboxformService.getValue().getEnum().getDisplayStr() 
//							+ com.fcscs.cservice.common.CServiceConstants.NOTIF_TMPL_DELIM_RIGHT);
//				}
//			}
//        });
//        titleMessageItemsComboxformService.addListener(Events.Focus , new Listener<FieldEvent>() {
//			@Override
//			public void handleEvent(FieldEvent be) {
//				if (null != titleMessageItemsComboxformService.getValue()) {
//					titleMessageItemsComboxformService.clear();
//					titleFieldformService.focus();
//				}
//			}
//		});
        
        titleFieldformService = new TextField<String>();
        titleFieldformService.setId("ExpressCheckInConfigPanel_titleFieldformService");
        titleFieldformService.setFieldLabel(ShareGWTConstants.SHARE_GWT_CONSTANTS.title() + CServiceConstants.FIELD_SEP);
        titleFieldformService.setWidth(400);
        titleFieldformService.setAllowBlank(false);
        titleFieldformService.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if(value != null 
				   && !value.trim().isEmpty()
				   && value.trim().length() > 100){
					return ShareGWTConstants.SHARE_GWT_MESSAGES.outOfLength(
							ShareGWTConstants.SHARE_GWT_CONSTANTS.title(), 100);
				}
				return null;
			}
        });
                
        HighLightIconButton icon3 = MultiEditBtn();
        
        
        HorizontalPanel messageforcheckinhp = new HorizontalPanel();
        VerticalPanel messageforcheckinlabelvp = new VerticalPanel();
        VerticalPanel messageforcheckintextfieldvp = new VerticalPanel();
        VerticalPanel messageforcheckiniconvp = new VerticalPanel();
        messageforcheckinhp.setSpacing(5);
        messageforcheckinlabelvp.setSpacing(8);
        messageforcheckinlabelvp.setWidth(100);
        messageforcheckintextfieldvp.setSpacing(5);
        messageforcheckiniconvp.setSpacing(8);
        
//        messageforcheckinlabelvp.add(messagefield1);
        messageforcheckinlabelvp.add(new Label(ShareGWTConstants.SHARE_GWT_CONSTANTS.title() + CServiceConstants.FIELD_SEP));
//        messageforcheckintextfieldvp.add(titleMessageItemsComboxformService);
        messageforcheckintextfieldvp.add(titleFieldformService);
        messageforcheckiniconvp.add(icon3);
        
        messageforcheckinhp.add(messageforcheckinlabelvp);
        messageforcheckinhp.add(messageforcheckintextfieldvp);
        messageforcheckinhp.add(messageforcheckiniconvp);
        
        lcCheckInMesTem.add(messageforcheckinhp);
        
        Label label2 = new Label("<html><font size=\"3\">" 
                + CServiceConstants.CSERVICE_CONSTANTS.expresscheckInRequestMessageTemplate()
                + "</font></html>");
	    label2.setId("ExpressCheckInConfigPanel_label2");
	    label2.setStyleAttribute(CServiceConstants.CSS_MARGINTOP, "80px");
	    
	    LayoutContainer lcCheckInMesTemAlert = new LayoutContainer();
		
		fieldsetCheckInMesTemAlert = new FieldSet();
		fieldsetCheckInMesTemAlert.setWidth(650);
		fieldsetCheckInMesTemAlert.setId("ExpressCheckInConfigPanel_fieldsetCheckInMesTemAlert");
		fieldsetCheckInMesTemAlert.setHeading(CServiceConstants.CSERVICE_CONSTANTS.expresscheckInRequestMessageTemplate());
		fieldsetCheckInMesTemAlert.add(lcCheckInMesTemAlert);
	    panel.add(fieldsetCheckInMesTemAlert);	    
	    
	    lcCheckInMesTemAlert.setId("ExpressCheckInConfigPanel_lcCheckInMesTemAlert");
	    layout = new FormLayout();
		layout.setLabelAlign(LabelAlign.LEFT);
		layout.setLabelWidth(130);
		layout.setDefaultWidth(360);
		layout.setLabelSeparator("");
		lcCheckInMesTemAlert.setLayout(layout);
		lcCheckInMesTemAlert.setBorders(false);
        
//        titleMessageItemsListStore = new ListStore<MessageItemsExpressGWTEnumModelData>();
//        for(MessageItemsExpressGWTEnum cm : MessageItemsExpressGWTEnum.values()){
//			titleMessageItemsListStore.add(new MessageItemsExpressGWTEnumModelData(cm));
//        }
//        titleMessageItemsCombox = new EasyClearCombobox<MessageItemsExpressGWTEnumModelData>();
//        titleMessageItemsCombox.setId("ExpressCheckInConfigPanel_titleMessageItemsCombox");
//        titleMessageItemsCombox.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.messageField() + CServiceConstants.FIELD_SEP);
////        messageItemsCombox.setWidth(200);
//        titleMessageItemsCombox.setStyleAttribute(CServiceConstants.CSS_MARGINTOP, "5px");
//        titleMessageItemsCombox.setDisplayField(CoreConstants.FULLTNAME);
//        titleMessageItemsCombox.setTriggerAction(TriggerAction.ALL);
//        titleMessageItemsCombox.setStore(titleMessageItemsListStore);
//        titleMessageItemsCombox.setForceSelection(true);
//        titleMessageItemsCombox.setEditable(false);
//        titleMessageItemsCombox.setWidth(400);
//        titleMessageItemsCombox.addSelectionChangedListener(new SelectionChangedListener<MessageItemsExpressGWTEnumModelData>(){
//			@Override
//			public void selectionChanged(
//					SelectionChangedEvent<MessageItemsExpressGWTEnumModelData> se) {
//				if(titleMessageItemsCombox.getValue() != null){
//					textAreaexpresscheckin.setValue((textAreaexpresscheckin.getValue() == null ? "" : textAreaexpresscheckin.getValue()) 
//							+ com.fcscs.cservice.common.CServiceConstants.NOTIF_TMPL_DELIM_LEFT 
//							+ titleMessageItemsCombox.getValue().getEnum().getDisplayStr() 
//							+ com.fcscs.cservice.common.CServiceConstants.NOTIF_TMPL_DELIM_RIGHT);
//				}
//			}
//        });
//        titleMessageItemsCombox.addListener(Events.Focus , new Listener<FieldEvent>() {
//			@Override
//			public void handleEvent(FieldEvent be) {
//				if (null != titleMessageItemsCombox.getValue()) {
//					titleMessageItemsCombox.clear();
//					textAreaexpresscheckin.focus();
//				}
//			}
//		});
        
        textAreaexpresscheckin = new TextArea();
        textAreaexpresscheckin.setId("ExpressCheckInConfigPanel_textAreatextAreaexpresscheckin");
        textAreaexpresscheckin.setHeight(130);
        textAreaexpresscheckin.setWidth(400);
        textAreaexpresscheckin.setAllowBlank(false);
        textAreaexpresscheckin.setFieldLabel(CoreConstants.CORE_CONSTANTS.details() + CServiceConstants.FIELD_SEP);
        textAreaexpresscheckin.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if(value != null 
				   && !value.trim().isEmpty()
				   && UIUtils.getCharCount(value.trim()) > 500){
					return ShareGWTConstants.SHARE_GWT_MESSAGES.outOfLength(
							CoreConstants.CORE_CONSTANTS.details(), 500);
				}
				return null;
			}
        });
        
        Label details = new Label(CoreConstants.CORE_CONSTANTS.details() + CServiceConstants.FIELD_SEP);
		HighLightIconButton icon6 = MultiEditBtn();
        
		HorizontalPanel messageforexpresscheckinhp = new HorizontalPanel();
        VerticalPanel messageforexpresscheckinlabelvp = new VerticalPanel();
        VerticalPanel messageforexpresscheckintextfieldvp = new VerticalPanel();
        VerticalPanel messageforexpresscheckiniconvp = new VerticalPanel();
        messageforexpresscheckinhp.setSpacing(5);
        messageforexpresscheckinlabelvp.setSpacing(8);
        messageforexpresscheckinlabelvp.setWidth(100);
        messageforexpresscheckintextfieldvp.setSpacing(5);
        messageforexpresscheckiniconvp.setSpacing(8);
        
//        messageforexpresscheckinlabelvp.add(messagefield2);
        messageforexpresscheckinlabelvp.add(details);
//        messageforexpresscheckintextfieldvp.add(titleMessageItemsCombox);
        messageforexpresscheckintextfieldvp.add(textAreaexpresscheckin);
//        messageforexpresscheckiniconvp.add(icon5);
        messageforexpresscheckiniconvp.add(icon6);
        
        messageforexpresscheckinhp.add(messageforexpresscheckinlabelvp);
        messageforexpresscheckinhp.add(messageforexpresscheckintextfieldvp);
        messageforexpresscheckinhp.add(messageforexpresscheckiniconvp);
        
        lcCheckInMesTemAlert.add(messageforexpresscheckinhp);
        
        messageItemsListStore = new ListStore<MessageItemsGWTEnumModelData>();
        for(MessageItemsGWTEnum cm : MessageItemsGWTEnum.values()){
//        	if (!cm.equals(MessageItemsGWTEnum.ROOM)) {
				messageItemsListStore.add(new MessageItemsGWTEnumModelData(cm));
//			}
        }
        messageItemsCombox = new EasyClearCombobox<MessageItemsGWTEnumModelData>();
        messageItemsCombox.setId("ExpressCheckInConfigPanel_messageItemsCombox");
        messageItemsCombox.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.messageField() + CServiceConstants.FIELD_SEP);
//        messageItemsCombox.setWidth(200);
        messageItemsCombox.setDisplayField(CoreConstants.FULLTNAME);
        messageItemsCombox.setTriggerAction(TriggerAction.ALL);
        messageItemsCombox.setStore(messageItemsListStore);
        messageItemsCombox.setForceSelection(true);
        messageItemsCombox.setEditable(false);
        messageItemsCombox.addSelectionChangedListener(new SelectionChangedListener<MessageItemsGWTEnumModelData>(){
			@Override
			public void selectionChanged(
					SelectionChangedEvent<MessageItemsGWTEnumModelData> se) {
				if(messageItemsCombox.getValue() != null){
					textArea.setValue((textArea.getValue() == null ? "" : textArea.getValue()) 
							+ com.fcscs.cservice.common.CServiceConstants.NOTIF_TMPL_DELIM_LEFT 
							+ messageItemsCombox.getValue().getEnum().getDisplayStr() 
							+ com.fcscs.cservice.common.CServiceConstants.NOTIF_TMPL_DELIM_RIGHT);
				}
			}
        });
        messageItemsCombox.addListener(Events.Focus , new Listener<FieldEvent>() {
			@Override
			public void handleEvent(FieldEvent be) {
				if (null != messageItemsCombox.getValue()) {
					messageItemsCombox.clear();
					textArea.focus();
				}
			}
		});
//        lcb.add(messageItemsCombox);
        
        textArea = new TextArea();
        textArea.setId("ExpressCheckInConfigPanel_textArea");
        textArea.setHeight(130);
        textArea.setFieldLabel(CoreConstants.CORE_CONSTANTS.details() + CServiceConstants.FIELD_SEP);
        textArea.setAllowBlank(false);
        textArea.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if(value != null 
				   && !value.trim().isEmpty()
				   && UIUtils.getCharCount(value.trim()) > 500){
					return ShareGWTConstants.SHARE_GWT_MESSAGES.outOfLength(
							CoreConstants.CORE_CONSTANTS.details(), 500);
				}
				return null;
			}
        });
//        lcb.add(textArea);
        
        LayoutContainer lcc = new LayoutContainer();
        lcc.setId("ExpressCheckInConfigPanel_lcc");
	    layout = new FormLayout();
		layout.setLabelAlign(LabelAlign.LEFT);
		layout.setLabelWidth(130);
		layout.setDefaultWidth(360);
		layout.setLabelSeparator("");
		lcc.setLayout(layout);
		lcc.setBorders(false);
		
		fieldset3 = new FieldSet();
		fieldset3.setWidth(650);
		fieldset3.setId("ExpressCheckInConfigPanel_fieldset3");
		fieldset3.setHeading(CServiceConstants.CSERVICE_CONSTANTS.checkInMonitor());
		fieldset3.add(lcc);
	    panel.add(fieldset3);
        
        Label label3 = new Label("<html><font size=\"3\">" 
                + CServiceConstants.CSERVICE_CONSTANTS.checkInMonitor()
                + "</font></html>");
        label3.setId("ExpressCheckInConfigPanel_label3");
        
        timeOutField = new TextField<String>();
        timeOutField.setId("ExpressCheckInConfigPanel_timeOutField");
        timeOutField.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.timeOut() + CServiceConstants.FIELD_SEP);
        timeOutField.setAllowBlank(false);
        timeOutField.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if(value == null){
					return CoreConstants.CORE_CONSTANTS.requiredField();
				}else if(value.trim().isEmpty()){
					return ShareGWTConstants.SHARE_GWT_CONSTANTS.cannotEmpty();
				}else if(!isValidNum(value.trim())){
					return CServiceConstants.CSERVICE_MESSAGES.enterNumBetweenAnd("1", "1440");
				}
				return null;
			}
        });
        
        timeOutField.addListener(Events.KeyUp, new Listener<BaseEvent>() {
			@Override
			public void handleEvent(BaseEvent be) {
				// TODO Auto-generated method stub
			
				if(!timeOutField.getValue().trim().equals(currentExpressCheckInConf.getCheckInMonitorTimeOut().toString()) || isChange){
					saveButton.setEnabled(true);
					isChange=true;
				}
				else
					saveButton.setEnabled(false);
			}
		});
        
        lcc.add(timeOutField);
        
        LayoutContainer lcd = new LayoutContainer();
        lcd.setId("ExpressCheckInConfigPanel_lcd");
	    layout = new FormLayout();
		layout.setLabelAlign(LabelAlign.LEFT);
		layout.setLabelWidth(130);
		layout.setDefaultWidth(360);
		layout.setLabelSeparator("");
		lcd.setLayout(layout);
		lcd.setBorders(false);
		
		fieldset4 = new FieldSet();
		fieldset4.setWidth(650);
		fieldset4.setId("ExpressCheckInConfigPanel_fieldset4");
		fieldset4.setHeading(CServiceConstants.CSERVICE_CONSTANTS.checkInTimeOutSendTo());
		fieldset4.add(lcd);
	    panel.add(fieldset4);
	    
	    Label label4 = new Label("<html><font size=\"3\">" 
                + CServiceConstants.CSERVICE_CONSTANTS.checkInTimeOutSendTo()
                + "</font></html>");
	    label4.setId("ExpressCheckInConfigPanel_label4");
	    
	    HorizontalPanel checkintimeoutsendtohp = new HorizontalPanel();
		VerticalPanel emailprinterradiotimeoutvp = new VerticalPanel();
		emailprinterradiotimeoutvp.setSpacing(5);
		VerticalPanel emailprintertexttimeoutvp = new VerticalPanel();
		emailprintertexttimeoutvp.setSpacing(5);
        
        emailRadioAlert = new Radio();
        emailRadioAlert.setId("ExpressCheckInConfigPanel_emailRadioAlert");
        emailRadioAlert.setBoxLabel(CServiceConstants.CSERVICE_CONSTANTS.emailAddress());
        emailRadioAlert.setValue(true);
        emailRadioAlert.addListener(Events.Change, new Listener<BaseEvent>(){
			@Override
			public void handleEvent(BaseEvent be) {
				if(emailRadioAlert.getValue()){
//					emailAddressField1.setVisible(true);
					if(currentExpressCheckInConf.getCheckInTimeOutAlertSentTo()==1)
						saveButton.setEnabled(true);
					emailAddressFieldAlert.setEnabled(true);
					emailAddressFieldAlert.focus();
					serverNameFieldAlert.clear();
				}else{
					emailAddressFieldAlert.setEnabled(false);
//					emailAddressField1.setVisible(false);
//					emailAddressField1.clear();
				}
			}
	    });

		printerRadioAlert = new Radio();
		printerRadioAlert.setId("ExpressCheckInConfigPanel_printerRadioAlert");
		printerRadioAlert.setBoxLabel(ShareGWTConstants.SHARE_GWT_CONSTANTS.printer() + " " + CServiceConstants.CSERVICE_CONSTANTS.serverName() + CServiceConstants.FIELD_SEP);
		printerRadioAlert.addListener(Events.Change, new Listener<BaseEvent>(){
			@Override
			public void handleEvent(BaseEvent be) {
				if(printerRadioAlert.getValue()){
//					serverNameField1.setVisible(true);
					if(currentExpressCheckInConf.getCheckInTimeOutAlertSentTo()==0)
						saveButton.setEnabled(true);
					serverNameFieldAlert.setEnabled(true);
					serverNameFieldAlert.focus();
					emailAddressFieldAlert.clear();
				}else{
//					serverNameField1.setVisible(false);
					serverNameFieldAlert.setEnabled(false);
//					serverNameField1.clear();
				}
			}
	    });

	    RadioGroup group1 = new RadioGroup();
	    group1.setId("ExpressCheckInConfigPanel_group1");
	    group1.add(emailRadioAlert);
	    group1.add(printerRadioAlert);
//	    lcd.add(group1);
	    
	    emailprinterradiotimeoutvp.add(emailRadioAlert);
	    emailprinterradiotimeoutvp.add(printerRadioAlert);
	    
	    emailAddressFieldAlert = new TextField<String>();
	    emailAddressFieldAlert.setId("ExpressCheckInConfigPanel_emailAddressField1");
	    emailAddressFieldAlert.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.emailAddress() + CServiceConstants.FIELD_SEP);
//	    emailAddressField.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "80px");
	    emailAddressFieldAlert.setVisible(true);
	    emailAddressFieldAlert.setEnabled(true);
	    emailAddressFieldAlert.setWidth(300);
	    emailAddressFieldAlert.setAllowBlank(false);
	    emailAddressFieldAlert.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if (!value.toUpperCase().matches(emailReg)) {
					return ShareGWTConstants.SHARE_GWT_CONSTANTS.emailErro();
				} else if (value.length() > 50) {
					return ShareGWTConstants.SHARE_GWT_MESSAGES.outOfLength(
							CoreConstants.CORE_CONSTANTS.email(), 50);
				}
				return null;
			}
        });
	    emailAddressFieldAlert.addListener(Events.KeyUp, new Listener<BaseEvent>() {

			@Override
			public void handleEvent(BaseEvent be) {
				// TODO Auto-generated method stub
				if(!emailAddressFieldAlert.getValue().trim().equals(currentExpressCheckInConf.getCheckInTimeOutPrinterEmail())||isChange){
					saveButton.setEnabled(true);
					isChange=true;
				}
				else
					saveButton.setEnabled(false);
			}
		});
//	    lcd.add(emailAddressField1);
	    
	    serverNameFieldAlert = new TextField<String>();
	    serverNameFieldAlert.setId("ExpressCheckInConfigPanel_serverNameField1");
	    serverNameFieldAlert.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.serverName() + CServiceConstants.FIELD_SEP);
//	    serverNameField.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "80px");
	    serverNameFieldAlert.setVisible(true);
	    serverNameFieldAlert.setEnabled(false);
	    serverNameFieldAlert.setWidth(300);
	    serverNameFieldAlert.setAllowBlank(false);
	    serverNameFieldAlert.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if(value != null 
				   && !value.trim().isEmpty()
				   && value.trim().length() > 50){
					return ShareGWTConstants.SHARE_GWT_MESSAGES.outOfLength(
							CServiceConstants.CSERVICE_CONSTANTS.serverName(), 50);
				}
				return null;
			}
        });
	    serverNameFieldAlert.addListener(Events.KeyUp, new Listener<BaseEvent>() {

			@Override
			public void handleEvent(BaseEvent be) {
				// TODO Auto-generated method stub
				if(!serverNameFieldAlert.getValue().trim().equals(currentExpressCheckInConf.getCheckInTimeOutPrinterEmail())||isChange){
					saveButton.setEnabled(true);
					isChange=true;
				}
				else
					saveButton.setEnabled(false);
			}
		});
//	    lcd.add(serverNameField1);
	    
	    emailprintertexttimeoutvp.add(emailAddressFieldAlert);
	    emailprintertexttimeoutvp.add(serverNameFieldAlert);
	    
	    checkintimeoutsendtohp.add(emailprinterradiotimeoutvp);
	    checkintimeoutsendtohp.add(emailprintertexttimeoutvp);
	    lcd.add(checkintimeoutsendtohp);
        
	    LayoutContainer lce = new LayoutContainer();
	    lce.setId("ExpressCheckInConfigPanel_lce");
	    layout = new FormLayout();
		layout.setLabelAlign(LabelAlign.LEFT);
		layout.setLabelWidth(130);
		layout.setDefaultWidth(360);
		layout.setLabelSeparator("");
		lce.setLayout(layout);
		lce.setBorders(false);
		
		fieldset5 = new FieldSet();
		fieldset5.setWidth(650);
		fieldset5.setId("ExpressCheckInConfigPanel_fieldset5");
		fieldset5.setHeading(CServiceConstants.CSERVICE_CONSTANTS.checkInRequestTimeOutMessage());
		fieldset5.add(lce);
	    panel.add(fieldset5);
		
		Label label5a = new Label("<html><font size=\"3\">" 
                + CServiceConstants.CSERVICE_CONSTANTS.subjectcheckin()
                + "</font></html>");
		label5a.setId("ExpressCheckInConfigPanel_label5a");
		
		subjectCheckinTimeout = new TextField<String>();
		subjectCheckinTimeout.setId("ExpressCheckInConfigPanel_subjectCheckinTimeout");
		subjectCheckinTimeout.setFieldLabel(ShareGWTConstants.SHARE_GWT_CONSTANTS.subject() + CServiceConstants.FIELD_SEP);
		subjectCheckinTimeout.setValue(CServiceConstants.CSERVICE_CONSTANTS.alertCheckin());
		subjectCheckinTimeout.setWidth(400);
		subjectCheckinTimeout.setReadOnly(true);
		subjectCheckinTimeout.setAllowBlank(false);
		subjectCheckinTimeout.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if(value != null 
				   && !value.trim().isEmpty()
				   && value.trim().length() > 50){
					return ShareGWTConstants.SHARE_GWT_MESSAGES.outOfLength(
							ShareGWTConstants.SHARE_GWT_CONSTANTS.subject(), 50);
				}
				return null;
			}
        });
		
		subjectCheckinRequestTimeoutDialog = new MultiLanguageDialog();
		subjectCheckinRequestTimeoutDialog.setAllowBlank(false);
		subjectCheckinRequestTimeoutDialog.addMultiLanguageDialogEventHandler(new MultiLanguageDialogEventHandler() {

			@Override
			public void onButtonOKClicked(
					MultiLanguageDialogOKEvent event) {
				// Get map language-text
				Map<String, String> values = event.getSource().getLanguageTexts();
				// Display English in label
				subjectCheckinTimeout.setValue(values.get(MultiLanguageDialog.DEFAULT_LANGUAGE));
				
				if(!currentSubjectAlertTimeout.equals(values.get(MultiLanguageDialog.DEFAULT_LANGUAGE))||isChange){
					saveButton.setEnabled(true);
					isChange=true;
				}
				else
					saveButton.setEnabled(false);
				//netTextField.setValue(values.get("ja"));
				//Info.display("result", values.get("en_us") + "-" + values.get("ko"));

			}
		});
		final HighLightIconButton subjectCheckinRequestTimeoutBtn = new HighLightIconButton(
				ShareGWTConstants.CSS_EDIT_SM_ICON,
				new SelectionListener<IconButtonEvent>() {
					@Override
					public void componentSelected(IconButtonEvent ce) {
						subjectCheckinRequestTimeoutDialog.show();
					}
				});
        
        Label subjectalert = new Label(ShareGWTConstants.SHARE_GWT_CONSTANTS.subject() + CServiceConstants.FIELD_SEP);

        
        HorizontalPanel subjectalerthp = new HorizontalPanel();
        VerticalPanel subjectalertlabelvp = new VerticalPanel();
        VerticalPanel subjectalerttextfieldvp = new VerticalPanel();
        VerticalPanel subjectalerticonvp = new VerticalPanel();
        
        subjectalerthp.setSpacing(5);
        subjectalertlabelvp.setSpacing(8);
        subjectalertlabelvp.setWidth(103);
        subjectalerttextfieldvp.setSpacing(5);
        subjectalerticonvp.setSpacing(8);
        
        subjectalertlabelvp.add(subjectalert);
        subjectalerttextfieldvp.add(subjectCheckinTimeout);
        subjectalerticonvp.add(subjectCheckinRequestTimeoutBtn);
        
        subjectalerthp.add(subjectalertlabelvp);
        subjectalerthp.add(subjectalerttextfieldvp);
        subjectalerthp.add(subjectalerticonvp);
        
        lce.add(subjectalerthp);
	    
	    Label label5 = new Label("<html><font size=\"3\">" 
                + CServiceConstants.CSERVICE_CONSTANTS.checkInRequestTimeOutMessageTemplate()
                + "</font></html>");
	    label5.setId("ExpressCheckInConfigPanel_label5");
	    
	    LayoutContainer lcCheckinTimeoutAlet = new LayoutContainer();
	    lcCheckinTimeoutAlet.setId("ExpressCheckInConfigPanel_lcCheckinTimeoutAlet");
	    layout = new FormLayout();
		layout.setLabelAlign(LabelAlign.LEFT);
		layout.setLabelWidth(130);
		layout.setDefaultWidth(360);
		layout.setLabelSeparator("");
		lcCheckinTimeoutAlet.setLayout(layout);
		lcCheckinTimeoutAlet.setBorders(false);
		
		fieldsetCheckInTimeoutAlet = new FieldSet();
		fieldsetCheckInTimeoutAlet.setWidth(650);
		fieldsetCheckInTimeoutAlet.setId("ExpressCheckInConfigPanel_fieldset5");
		fieldsetCheckInTimeoutAlet.setHeading(CServiceConstants.CSERVICE_CONSTANTS.checkInRequestTimeOutMessageTemplate());
		fieldsetCheckInTimeoutAlet.add(lcCheckinTimeoutAlet);
	    panel.add(fieldsetCheckInTimeoutAlet);
        
//        titleMessageItemsListStore1 = new ListStore<MessageItemsGWTEnumModelData>();
//        for(MessageItemsGWTEnum cm : MessageItemsGWTEnum.values()){
//			titleMessageItemsListStore1.add(new MessageItemsGWTEnumModelData(cm));
//        }
//        titleMessageItemsCombox1 = new EasyClearCombobox<MessageItemsGWTEnumModelData>();
//        titleMessageItemsCombox1.setId("ExpressCheckInConfigPanel_titleMessageItemsCombox1");
//        titleMessageItemsCombox1.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.messageField() + CServiceConstants.FIELD_SEP);
////        messageItemsCombox.setWidth(200);
//        titleMessageItemsCombox1.setDisplayField(CoreConstants.FULLTNAME);
//        titleMessageItemsCombox1.setTriggerAction(TriggerAction.ALL);
//        titleMessageItemsCombox1.setStore(titleMessageItemsListStore1);
//        titleMessageItemsCombox1.setForceSelection(true);
//        titleMessageItemsCombox1.setEditable(false);
//        titleMessageItemsCombox1.setWidth(400);
//        titleMessageItemsCombox1.addSelectionChangedListener(new SelectionChangedListener<MessageItemsGWTEnumModelData>(){
//			@Override
//			public void selectionChanged(
//					SelectionChangedEvent<MessageItemsGWTEnumModelData> se) {
//				if(titleMessageItemsCombox1.getValue() != null){
//					titleField1.setValue((titleField1.getValue() == null ? "" : titleField1.getValue()) 
//							+ com.fcscs.cservice.common.CServiceConstants.NOTIF_TMPL_DELIM_LEFT 
//							+ titleMessageItemsCombox1.getValue().getEnum().getDisplayStr() 
//							+ com.fcscs.cservice.common.CServiceConstants.NOTIF_TMPL_DELIM_RIGHT);
//					
//					textArea1.setValue((textArea1.getValue() == null ? "" : textArea1.getValue()) 
//							+ com.fcscs.cservice.common.CServiceConstants.NOTIF_TMPL_DELIM_LEFT 
//							+ titleMessageItemsCombox1.getValue().getEnum().getDisplayStr() 
//							+ com.fcscs.cservice.common.CServiceConstants.NOTIF_TMPL_DELIM_RIGHT);
//				}
//			}
//        });
//        titleMessageItemsCombox1.addListener(Events.Focus , new Listener<FieldEvent>() {
//			@Override
//			public void handleEvent(FieldEvent be) {
//				if (null != titleMessageItemsCombox1.getValue()) {
//					titleMessageItemsCombox1.clear();
//					titleField1.focus();
//				}
//			}
//		});
        
        titleField1 = new TextField<String>();
        titleField1.setId("ExpressCheckInConfigPanel_titleField1");
        titleField1.setFieldLabel(ShareGWTConstants.SHARE_GWT_CONSTANTS.title() + CServiceConstants.FIELD_SEP);
        titleField1.setValue(CServiceConstants.CSERVICE_CONSTANTS.alertCheckin());
        titleField1.setWidth(400);
        titleField1.setAllowBlank(false);
        titleField1.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if(value != null 
				   && !value.trim().isEmpty()
				   && value.trim().length() > 50){
					return ShareGWTConstants.SHARE_GWT_MESSAGES.outOfLength(
							ShareGWTConstants.SHARE_GWT_CONSTANTS.title(), 50);
				}
				return null;
			}
        });
        
        textArea1 = new TextArea();
        textArea1.setId("ExpressCheckInConfigPanel_textArea1");
        textArea1.setHeight(130);
        textArea1.setFieldLabel(CoreConstants.CORE_CONSTANTS.details() + CServiceConstants.FIELD_SEP);
        textArea1.setValue("plase");
        textArea1.setWidth(400);
        textArea1.setAllowBlank(false);
        textArea1.setValidator(new Validator(){
			@Override
			public String validate(Field<?> field, String value) {
				if(value != null 
				   && !value.trim().isEmpty()
				   && UIUtils.getCharCount(value.trim()) > 500){
					return ShareGWTConstants.SHARE_GWT_MESSAGES.outOfLength(
							CoreConstants.CORE_CONSTANTS.details(), 500);
				}
				return null;
			}
        });
        
        HighLightIconButton icon9 = MultiEditBtn();
        HighLightIconButton icon10 = MultiEditBtn();
        
        HorizontalPanel alertmessagethp = new HorizontalPanel();
        VerticalPanel alertmessagelabelvp = new VerticalPanel();
        VerticalPanel alertmessagetextfieldvp = new VerticalPanel();
        VerticalPanel alertmessageiconvp = new VerticalPanel();
        
        alertmessagethp.setSpacing(5);
        alertmessagelabelvp.setSpacing(8);
        alertmessagelabelvp.setWidth(100);
        alertmessagetextfieldvp.setSpacing(5);
        alertmessageiconvp.setSpacing(8);
        
//        alertmessagelabelvp.add(messagefield3);
        alertmessagelabelvp.add(new Label(ShareGWTConstants.SHARE_GWT_CONSTANTS.title() + CServiceConstants.FIELD_SEP));
        alertmessagelabelvp.add(new Label(CoreConstants.CORE_CONSTANTS.details() + CServiceConstants.FIELD_SEP));
//        alertmessagetextfieldvp.add(titleMessageItemsCombox1);
        alertmessagetextfieldvp.add(titleField1);
        alertmessagetextfieldvp.add(textArea1);
//        alertmessageiconvp.add(icon8);
        alertmessageiconvp.add(icon9);
        alertmessageiconvp.add(icon10);
        
        alertmessagethp.add(alertmessagelabelvp);
        alertmessagethp.add(alertmessagetextfieldvp);
        alertmessagethp.add(alertmessageiconvp);
        
        lcCheckinTimeoutAlet.add(alertmessagethp);
        
        LayoutContainer lcf = new LayoutContainer();
        lcf.setId("ExpressCheckInConfigPanel_lcf");
	    layout = new FormLayout();
		layout.setLabelAlign(LabelAlign.LEFT);
		layout.setLabelWidth(130);
		layout.setDefaultWidth(360);
		layout.setLabelSeparator("");
		lcf.setLayout(layout);
		lcf.setBorders(false);
		
		fieldset6 = new FieldSet();
		fieldset6.setWidth(650);
		fieldset6.setId("ExpressCheckInConfigPanel_fieldset6");
		fieldset6.setHeading(CServiceConstants.CSERVICE_CONSTANTS.checkInRequest());
		fieldset6.add(lcf);
	    panel.add(fieldset6);
        
        ackField = new TextField<String>();
        ackField.setId("ExpressCheckInConfigPanel_ackField");
        ackField.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.ackMessage() + CServiceConstants.FIELD_SEP);
	    
        checkinrequestsubmitted = new TextField<String>();
        checkinrequestsubmitted.setAllowBlank(false);
        checkinrequestsubmitted.setReadOnly(true);
        checkinrequestsubmitted.setId("ExpressCheckInConfigPanel_checkinrequestsubmitted");
        checkinrequestsubmitted.setWidth(400);
//        checkinrequestsubmitted.setFieldLabel(CServiceConstants.CSERVICE_CONSTANTS.checkinrequestsubmitted() + CServiceConstants.FIELD_SEP);
        
        checkinRequestSubmittedDialog = new MultiLanguageDialog();
        checkinRequestSubmittedDialog.setAllowBlank(false);
        checkinRequestSubmittedDialog.addMultiLanguageDialogEventHandler(new MultiLanguageDialogEventHandler() {

			@Override
			public void onButtonOKClicked(
					MultiLanguageDialogOKEvent event) {
				// Get map language-text
				Map<String, String> values = event.getSource().getLanguageTexts();
				// Display English in label
				checkinrequestsubmitted.setValue(values.get(MultiLanguageDialog.DEFAULT_LANGUAGE));
				
				if(!currentCheckinSubmitted.equals(values.get(MultiLanguageDialog.DEFAULT_LANGUAGE))||isChange){
					saveButton.setEnabled(true);
					isChange = true;
				}
				else
					saveButton.setEnabled(false);
				//netTextField.setValue(values.get("ja"));
				//Info.display("result", values.get("en_us") + "-" + values.get("ko"));

			}
		});
		final HighLightIconButton checkinRequestSubmittedBtn = new HighLightIconButton(
				ShareGWTConstants.CSS_EDIT_SM_ICON,
				new SelectionListener<IconButtonEvent>() {
					@Override
					public void componentSelected(IconButtonEvent ce) {
						checkinRequestSubmittedDialog.show();
					}
				});
        
        HorizontalPanel checkinsubmittedhp = new HorizontalPanel();
        VerticalPanel checkinsubmittedLabelVp = new VerticalPanel();
        VerticalPanel checkinsubmittedTextfieldVp = new VerticalPanel();
        VerticalPanel checkinsubmittedIconVp = new VerticalPanel();
        checkinsubmittedhp.setSpacing(5);
        checkinsubmittedLabelVp.setWidth(120);
        checkinsubmittedIconVp.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "10px");
        checkinsubmittedLabelVp.add(new Label(CServiceConstants.CSERVICE_CONSTANTS.requestsubmitted() + CServiceConstants.FIELD_SEP));
        checkinsubmittedTextfieldVp.add(checkinrequestsubmitted);
        checkinsubmittedIconVp.add(checkinRequestSubmittedBtn);
        checkinsubmittedhp.add(checkinsubmittedLabelVp);
        checkinsubmittedhp.add(checkinsubmittedTextfieldVp);
        checkinsubmittedhp.add(checkinsubmittedIconVp);
        
        lcf.add(checkinsubmittedhp);
        
        alreadycheckin = new TextField<String>();
	    alreadycheckin.setReadOnly(true);
	    alreadycheckin.setAllowBlank(false);
        alreadycheckin.setId("ExpressCheckInConfigPanel_alreadycheckin");
        alreadycheckin.setWidth(400);
        
        alreadyCheckinDialog = new MultiLanguageDialog();
        alreadyCheckinDialog.setAllowBlank(false);
        alreadyCheckinDialog.addMultiLanguageDialogEventHandler(new MultiLanguageDialogEventHandler() {

			@Override
			public void onButtonOKClicked(
					MultiLanguageDialogOKEvent event) {
				// Get map language-text
				Map<String, String> values = event.getSource().getLanguageTexts();
				// Display English in label
				alreadycheckin.setValue(values.get(MultiLanguageDialog.DEFAULT_LANGUAGE));
				
				if(!currentAlreadyCheckin.equals(values.get(MultiLanguageDialog.DEFAULT_LANGUAGE))||isChange){
					saveButton.setEnabled(true);
					isChange=true;
				}
				else
					saveButton.setEnabled(false);
				//netTextField.setValue(values.get("ja"));
				//Info.display("result", values.get("en_us") + "-" + values.get("ko"));

			}
		});
        
		final HighLightIconButton alreadyCheckinBtn = new HighLightIconButton(
				ShareGWTConstants.CSS_EDIT_SM_ICON,
				new SelectionListener<IconButtonEvent>() {
					@Override
					public void componentSelected(IconButtonEvent ce) {
						alreadyCheckinDialog.show();
					}
				});
        
        HorizontalPanel alreadycheckindhp = new HorizontalPanel();
        VerticalPanel alreadycheckinLabelVp = new VerticalPanel();
        VerticalPanel alreadycheckinTextfieldVp = new VerticalPanel();
        VerticalPanel alreadycheckinIconVp = new VerticalPanel();
        alreadycheckindhp.setSpacing(5);
        alreadycheckinLabelVp.setWidth(120);
        alreadycheckinIconVp.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "10px");
        alreadycheckinLabelVp.add(new Label(CServiceConstants.CSERVICE_CONSTANTS.alreadycheckin() + CServiceConstants.FIELD_SEP));
        alreadycheckinTextfieldVp.add(alreadycheckin);
        alreadycheckinIconVp.add(alreadyCheckinBtn);
        alreadycheckindhp.add(alreadycheckinLabelVp);
        alreadycheckindhp.add(alreadycheckinTextfieldVp);
        alreadycheckindhp.add(alreadycheckinIconVp);
        
        lcf.add(alreadycheckindhp);
        
	    vp.add(panel);
	    
//	    FormButton saveButton = new FormButton(CoreConstants.CORE_CONSTANTS.save());
	    saveButton = new FormButton(CoreConstants.CORE_CONSTANTS.save());
	    saveButton.setId("ExpressCheckInConfigPanel_saveButton");
		saveButton.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "560px");
//		if(isChange)
//			saveButton.setEnabled(true);
//		else
//			saveButton.setEnabled(false);
		saveButton.setSize(60, 30);
		saveButton.setEnabled(false);
		saveButton.addSelectionListener(new SelectionListener<ButtonEvent>(){
			@Override
			public void componentSelected(ButtonEvent ce) {
				
					if(timeOutField.isValid() && fromExpressCheckin.isValid() && subjectCheckin.isValid()
							&& subjectCheckinTimeout.isValid() && checkinrequestsubmitted.isValid() && alreadycheckin.isValid()
							&& (emailAddressField.isEnabled() ? emailAddressField.isValid() : true)
							&& (serverNameField.isEnabled() ? serverNameField.isValid() : true)
							&& (emailAddressFieldAlert.isEnabled() ? emailAddressFieldAlert.isValid() : true)
							&& (serverNameFieldAlert.isEnabled() ? serverNameFieldAlert.isValid() : true)){
						
						if(emailRadio.getValue()){
							currentExpressCheckInConf.setCheckInRequestSendTo(0);
							currentExpressCheckInConf.setCheckInPrinterEmail(emailAddressField.getValue());
						}
						else{
							currentExpressCheckInConf.setCheckInRequestSendTo(1);
							currentExpressCheckInConf.setCheckInPrinterEmail(serverNameField.getValue());
						}
						currentExpressCheckInConf.setCheckInMonitorTimeOut(Integer.parseInt(timeOutField.getValue()));
						if(emailRadioAlert.getValue()){
							currentExpressCheckInConf.setCheckInTimeOutAlertSentTo(0);
							currentExpressCheckInConf.setCheckInTimeOutPrinterEmail(emailAddressFieldAlert.getValue());
						}
						else{
							currentExpressCheckInConf.setCheckInTimeOutAlertSentTo(1);
							currentExpressCheckInConf.setCheckInTimeOutPrinterEmail(serverNameFieldAlert.getValue());
						}
						CServiceCommonServiceController.getINSTANCE().saveExpressCheckInConfig(currentExpressCheckInConf,
							new AsyncCallbackListener<ExpressCheckInConfig>(){
	
								@Override
								public void onLogin(String username) {
									// TODO Auto-generated method stub
									CServiceCommonServiceController.getINSTANCE().saveExpressCheckInConfig(currentExpressCheckInConf, this);
								}
	
								@Override
								public void onFailure(Throwable caught) {
									// TODO Auto-generated method stub
									MessageBox.alert(CoreConstants.CORE_MESSAGES.operation(CoreConstants.CORE_CONSTANTS.system(), ShareGWTConstants.SHARE_GWT_CONSTANTS.error()),
											CoreConstants.CORE_CONSTANTS.systemError(), null);
								}
	
								@Override
								public void onSuccess(ExpressCheckInConfig result) {
									// TODO Auto-generated method stub
									if(null != result){
										CenteredInfo.displayCompleted(CoreConstants.CORE_CONSTANTS.edited());
									}
								}
						});
						
						saveMultiLanguageMap(fromExpresscheckinMap, MultiLanguageConstants.fromExpressCheckIn);
						saveMultiLanguageMap(subjectCheckinRequestMap, MultiLanguageConstants.subjectCheckInRequets);
						saveMultiLanguageMap(subjectCheckinRequestTimeoutMap, MultiLanguageConstants.subjectCheckInRequetsTimeout);
						saveMultiLanguageMap(checkinRequestSubmittedMap, MultiLanguageConstants.checkinRequestSubmitted);
						saveMultiLanguageMap(alreadyCheckinMap, MultiLanguageConstants.alreadyCheckin);
						
						onShow();
						saveButton.setEnabled(false);
						isChange=false;
					}
			}
		});
		
	    vp.add(saveButton);
		
	    CServiceCommonServiceController.getINSTANCE().getLanguageMap(
			new AsyncCallbackListener<Map<String, String>>() {

				@Override
				public void onLogin(String username) {
					CServiceCommonServiceController.getINSTANCE().getLanguageMap(this);
				}

				@Override
				public void onSuccess(Map<String, String> result) {
					final Map<String, String> languages = result;
					fromDialog.setLanguages(languages);
					subjectCheckinRequestDialog.setLanguages(languages);
					subjectCheckinRequestTimeoutDialog.setLanguages(languages);
					subjectCheckinRequestTimeoutDialog.setLanguages(languages);
					checkinRequestSubmittedDialog.setLanguages(languages);
					alreadyCheckinDialog.setLanguages(languages);
				}

				@Override
				public void onFailure(Throwable caught) {
					Info.display("failure", caught.getMessage());
				}
		});
	    
	    add(vp);
		onShow();
	}

	@Override
	public UserAuthority getRequiredAuthority() {
		return CServiceAuthority.cSERVICE_CONFIG;
	}

	@Override
	protected Widget getViewPanel() {
		return vp;
	}

	@Override
	public void onShow() {
		loadProperty();
		myClear();
		//get non language
		CServiceCommonServiceController.getINSTANCE().getExpressCheckInConfig(
			SessionContext.getInstance().getPropertyId(), 
			new AsyncCallbackListener<ExpressCheckInConfig>(){

				@Override
				public void onLogin(String username) {
					// TODO Auto-generated method stub
					CServiceCommonServiceController.getINSTANCE().getExpressCheckInConfig
					(SessionContext.getInstance().getPropertyId(), this);
				}

				@Override
				public void onFailure(Throwable caught) {
					// TODO Auto-generated method stub
					MessageBox.alert(CoreConstants.CORE_MESSAGES.operation(CoreConstants.CORE_CONSTANTS.system(), ShareGWTConstants.SHARE_GWT_CONSTANTS.error()),
							CoreConstants.CORE_CONSTANTS.systemError(), null);
				}

				@Override
				public void onSuccess(ExpressCheckInConfig result) {
					// TODO Auto-generated method stub
					if(null != result){
						currentExpressCheckInConf = result;
						if(result.getCheckInRequestSendTo()==0){
							emailRadio.setValue(true);
							emailAddressField.setEnabled(true);
							emailAddressField.setValue(result.getCheckInPrinterEmail());
							printerRadio.setValue(false);
							serverNameField.setEnabled(false);
						}
						else{
							printerRadio.setValue(true);
							serverNameField.setEnabled(true);
							serverNameField.setValue(result.getCheckInPrinterEmail());
							emailRadio.setValue(false);
							emailAddressField.setEnabled(false);
						}
						
						timeOutField.setValue(result.getCheckInMonitorTimeOut().toString());
						
						if(result.getCheckInTimeOutAlertSentTo()==0){
							emailRadioAlert.setValue(true);
							emailAddressFieldAlert.setEnabled(true);
							emailAddressFieldAlert.setValue(result.getCheckInTimeOutPrinterEmail());
							printerRadioAlert.setValue(false);
							serverNameFieldAlert.setEnabled(false);
						}
						else{
							printerRadioAlert.setValue(true);
							serverNameFieldAlert.setEnabled(true);
							serverNameFieldAlert.setValue(result.getCheckInTimeOutPrinterEmail());
							emailRadioAlert.setValue(false);
							emailAddressFieldAlert.setEnabled(false);
						}
					}
				}
			});
		
			//get from express check in language
				
			CServiceCommonServiceController.getINSTANCE().getListConstantsLanguage(SessionContext.getInstance().getPropertyId(), SessionContext.getInstance().getOrgId(), MultiLanguageConstants.fromExpressCheckIn,
					new AsyncCallbackListener<List<ConstantsLanguageValue>>(){
	
				@Override
				public void onLogin(String username) {
					CServiceCommonServiceController.getINSTANCE().getListConstantsLanguage(SessionContext.getInstance().getPropertyId(),SessionContext.getInstance().getOrgId(), MultiLanguageConstants.fromExpressCheckIn,this);	
					Window.alert("login success!");
				}
	
				@Override
				public void onFailure(Throwable caught) {
					MessageBox.alert(CoreConstants.CORE_MESSAGES.operation(CoreConstants.CORE_CONSTANTS.system(), ShareGWTConstants.SHARE_GWT_CONSTANTS.error()),
							CoreConstants.CORE_CONSTANTS.systemError(), null);
					Window.alert("get language fail!");
				}
			
				@Override
				public void onSuccess(
					List<ConstantsLanguageValue> result1) {
					fromExpresscheckinMap = convertToMap(result1);
					fromExpressCheckin.setValue(fromExpresscheckinMap.get("en_us"));
					currentFromExpressCheckIn = fromExpressCheckin.getValue();
					//netTextField.setValue(networkAccessNotAvailableConf.get(SessionContext.getInstance().getPropertyLanguage().getDisplayStr()));
					fromDialog.setLanguageTexts(fromExpresscheckinMap);
				}
			});
			
			//get subject check in request language
			
			CServiceCommonServiceController.getINSTANCE().getListConstantsLanguage(SessionContext.getInstance().getPropertyId(), SessionContext.getInstance().getOrgId(), MultiLanguageConstants.subjectCheckInRequets,
					new AsyncCallbackListener<List<ConstantsLanguageValue>>(){


				@Override
				public void onLogin(String username) {
					CServiceCommonServiceController.getINSTANCE().getListConstantsLanguage(SessionContext.getInstance().getPropertyId(),SessionContext.getInstance().getOrgId(),MultiLanguageConstants.subjectCheckInRequets,this);	
					Window.alert("login success!");
				}
	
				@Override
				public void onFailure(Throwable caught) {
					MessageBox.alert(CoreConstants.CORE_MESSAGES.operation(CoreConstants.CORE_CONSTANTS.system(), ShareGWTConstants.SHARE_GWT_CONSTANTS.error()),
							CoreConstants.CORE_CONSTANTS.systemError(), null);
					Window.alert("get language fail!");
				}
			
	
				@Override
				public void onSuccess(
					List<ConstantsLanguageValue> result1) {
					subjectCheckinRequestMap = convertToMap(result1);
					subjectCheckin.setValue(subjectCheckinRequestMap.get("en_us"));
					currentSubjectCheckInRequest = subjectCheckin.getValue();
					//netTextField.setValue(networkAccessNotAvailableConf.get(SessionContext.getInstance().getPropertyLanguage().getDisplayStr()));
					subjectCheckinRequestDialog.setLanguageTexts(subjectCheckinRequestMap);
				}
			});
			
			//get subject check in request timeout language
			
			CServiceCommonServiceController.getINSTANCE().getListConstantsLanguage(SessionContext.getInstance().getPropertyId(), SessionContext.getInstance().getOrgId(), MultiLanguageConstants.subjectCheckInRequetsTimeout,
					new AsyncCallbackListener<List<ConstantsLanguageValue>>(){
	
				@Override
				public void onLogin(String username) {
					CServiceCommonServiceController.getINSTANCE().getListConstantsLanguage(SessionContext.getInstance().getPropertyId(),SessionContext.getInstance().getOrgId(),MultiLanguageConstants.subjectCheckInRequetsTimeout,this);	
					Window.alert("login success!");
				}
	
				@Override
				public void onFailure(Throwable caught) {
					MessageBox.alert(CoreConstants.CORE_MESSAGES.operation(CoreConstants.CORE_CONSTANTS.system(), ShareGWTConstants.SHARE_GWT_CONSTANTS.error()),
							CoreConstants.CORE_CONSTANTS.systemError(), null);
					Window.alert("get language fail!");
				}
			
				@Override
				public void onSuccess(
					List<ConstantsLanguageValue> result1) {
					subjectCheckinRequestTimeoutMap = convertToMap(result1);
					subjectCheckinTimeout.setValue(subjectCheckinRequestTimeoutMap.get("en_us"));
					currentSubjectAlertTimeout = subjectCheckinTimeout.getValue();
					//netTextField.setValue(networkAccessNotAvailableConf.get(SessionContext.getInstance().getPropertyLanguage().getDisplayStr()));
					subjectCheckinRequestTimeoutDialog.setLanguageTexts(subjectCheckinRequestTimeoutMap);
				}
			});
			
			//get check in submitted language
			
			CServiceCommonServiceController.getINSTANCE().getListConstantsLanguage(SessionContext.getInstance().getPropertyId(), SessionContext.getInstance().getOrgId(), MultiLanguageConstants.checkinRequestSubmitted,
					new AsyncCallbackListener<List<ConstantsLanguageValue>>(){
	
				@Override
				public void onLogin(String username) {
					CServiceCommonServiceController.getINSTANCE().getListConstantsLanguage(SessionContext.getInstance().getPropertyId(),SessionContext.getInstance().getOrgId(),MultiLanguageConstants.checkinRequestSubmitted,this);	
					Window.alert("login success!");
				}
	
				@Override
				public void onFailure(Throwable caught) {
					MessageBox.alert(CoreConstants.CORE_MESSAGES.operation(CoreConstants.CORE_CONSTANTS.system(), ShareGWTConstants.SHARE_GWT_CONSTANTS.error()),
							CoreConstants.CORE_CONSTANTS.systemError(), null);
					Window.alert("get language fail!");
				}
			
				@Override
				public void onSuccess(
					List<ConstantsLanguageValue> result1) {
					checkinRequestSubmittedMap = convertToMap(result1);
					checkinrequestsubmitted.setValue(checkinRequestSubmittedMap.get("en_us"));
					currentCheckinSubmitted = checkinRequestSubmittedMap.get("en_us");
					//netTextField.setValue(networkAccessNotAvailableConf.get(SessionContext.getInstance().getPropertyLanguage().getDisplayStr()));
					checkinRequestSubmittedDialog.setLanguageTexts(checkinRequestSubmittedMap);
				}
			});
			
			//get already check in language
			
			CServiceCommonServiceController.getINSTANCE().getListConstantsLanguage(SessionContext.getInstance().getPropertyId(), SessionContext.getInstance().getOrgId(), MultiLanguageConstants.alreadyCheckin,
					new AsyncCallbackListener<List<ConstantsLanguageValue>>(){
	
				@Override
				public void onLogin(String username) {
					CServiceCommonServiceController.getINSTANCE().getListConstantsLanguage(SessionContext.getInstance().getPropertyId(),SessionContext.getInstance().getOrgId(),MultiLanguageConstants.alreadyCheckin,this);	
					Window.alert("login success!");
				}
	
				@Override
				public void onFailure(Throwable caught) {
					MessageBox.alert(CoreConstants.CORE_MESSAGES.operation(CoreConstants.CORE_CONSTANTS.system(), ShareGWTConstants.SHARE_GWT_CONSTANTS.error()),
							CoreConstants.CORE_CONSTANTS.systemError(), null);
					Window.alert("get language fail!");
				}
			
				@Override
				public void onSuccess(
					List<ConstantsLanguageValue> result1) {
					alreadyCheckinMap = convertToMap(result1);
					alreadycheckin.setValue(alreadyCheckinMap.get("en_us"));
					currentAlreadyCheckin = alreadyCheckinMap.get("en_us");
					//netTextField.setValue(networkAccessNotAvailableConf.get(SessionContext.getInstance().getPropertyLanguage().getDisplayStr()));
					alreadyCheckinDialog.setLanguageTexts(alreadyCheckinMap);
				}
			});

	}
	
	public Map<String, String> convertToMap( List<ConstantsLanguageValue> listlang ){
		Map<String, String> resultmap = new HashMap<String, String>();
		for(ConstantsLanguageValue lang : listlang){
			resultmap.put(lang.getId().getLanguageId(), lang.getValue());
		}
		return resultmap;
		
	}

	@Override
	public boolean onHide() {
		myClear();
		return true;
	}
	
	private void saveMultiLanguageMap(Map<String, String> abc, String constants){

		for (Entry<String, String> entry : abc.entrySet()) {
			//Window.alert("Key : " + entry.getKey() + " Value : " + entry.getValue());
			if(entry.getValue()!=null){
				final ConstantsLanguageValue multiconstants=new ConstantsLanguageValue();
//				SessionContext.getInstance().getPropertyId()
				//constants=new ConstantsLanguageValueId();
				multiconstants.setId(new ConstantsLanguageValueId(SessionContext.getInstance().getPropertyId(), SessionContext.getInstance().getOrgId(), constants, entry.getKey()));
				//multiconstants.setId(new ConstantsLanguageValueId(1, 1, "NETWORK_ACCESS_NOT_AVAILABLE", entry.getKey()));
				multiconstants.setValue(entry.getValue());
				multiconstants.setCreated(new Date());
				multiconstants.setUpdated(new Date());
				multiconstants.setCreatedBy(SessionContext.getInstance().getUserId());
				multiconstants.setUpdatedBy(SessionContext.getInstance().getUserId());
				
				CServiceCommonServiceController.getINSTANCE().saveConstantsLanguageValue(multiconstants,
						new AsyncCallbackListener<ConstantsLanguageValue>() {

							@Override
							public void onLogin(String username) {
								CServiceCommonServiceController.getINSTANCE()
										.saveConstantsLanguageValue(multiconstants, this);
							}

							@Override
							public void onFailure(Throwable caught) {
								MessageBox.alert(CoreConstants.CORE_MESSAGES.operation(
										CoreConstants.CORE_CONSTANTS.system(),
										ShareGWTConstants.SHARE_GWT_CONSTANTS.error()),
										CoreConstants.CORE_CONSTANTS.systemError(),null);
							}

							@Override
							public void onSuccess(ConstantsLanguageValue result) {
								if (result != null) {
									CenteredInfo.displayCompleted(CoreConstants.CORE_CONSTANTS.edited());
								} else {
									MessageBox.alert(
											CoreConstants.CORE_MESSAGES.operation(
													CoreConstants.CORE_CONSTANTS.system(),
													ShareGWTConstants.SHARE_GWT_CONSTANTS.error()),
											CoreConstants.CORE_CONSTANTS.systemError(),null);
								}
							}
				});
			}//Dong if
		}//Dong For
		//CServiceCommonServiceController.getINSTANCE().saveConstantsLanguageValue(constants, callback);
	}
	
	private void myClear(){
		emailAddressField.clear();
		serverNameField.clear();
//		titleField.clear();
//		textArea.clear();
//		timeOutField.clear();
//		emailAddressFieldAlert.clear();
//		serverNameFieldAlert.clear();
//		titleField1.clear();
//		textArea1.clear();
	}
	
	private boolean isValidNum(String minutes){
		boolean isValid = true;
		for(int i = 0; i < minutes.length() ; i++){
			if(!Character.isDigit(minutes.charAt(i))){
				isValid = false;
				break;
			}
		}
		BigDecimal bd = new BigDecimal(minutes);
		if(isValid && ((bd.compareTo(new BigDecimal(Integer.valueOf(1440))) == 1)
			       || (bd.compareTo(new BigDecimal(Integer.valueOf(1))) == -1))){
			isValid = false;
		}
		return isValid;
	}

	@Override
	public void setFocus() {
		if(isFocus){
			emailAddressField.focus();
		}else{
			serverNameField.focus();
		}
	}
	
	private void loadProperty() {
		propGroupIdNames = SessionContext.getInstance().getPropertyGroup();
		propListStore.removeAll();
		if (0 != propGroupIdNames.size()) {
			int propIndex = 0;
			for (IdNameModel<Property> inm : propGroupIdNames) {
				propListStore.add(new PropertyIdNameModelData(inm));
				if (propIndex == 0) {
					if (SessionContext.getInstance().getPropertyId() == inm.getId()) {
						propIndex = propListStore.getCount() - 1;
					}
				}
			}
			propCombox.setValue(propListStore.getAt(propIndex));
		} else {
			IdNameModel<Property> tempINM = new IdNameModel<Property>(SessionContext.getInstance().getPropertyId(), SessionContext.getInstance().getPropertyName());
			propListStore.add(new PropertyIdNameModelData(tempINM));
			propCombox.setValue(propListStore.getAt(0));
		}
//		propListStore.removeAll();
//		IdNameModel<Property> tempINM = new IdNameModel<Property>(SessionContext.getInstance().getPropertyId(), SessionContext.getInstance().getPropertyName());
//		propListStore.add(new PropertyIdNameModelData(tempINM));
//		propCombox.setValue(propListStore.getAt(0));
//		grid.setCurrentProperty(propListStore.getAt(0));
	}
}

